package com.yc.hwc.bean;

import java.sql.Timestamp;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;

import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Data;

@Entity
@Table
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class User  implements java.io.Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Column(columnDefinition = "timestamp default CURRENT_TIMESTAMP")
	private Timestamp inTime;
	@OneToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
	@JoinColumn(name = "in_user")
	private User inUser;

	@Column(length = 50)
	@NotEmpty(message = "账号不能为空！")
	@Length(message="账号长度必须为2~10个字符！")
	private String account;
	@Column(length = 50)
	@NotEmpty(message = "姓名不能为空！")
	@Length(message="姓名长度必须为2~10个字符！")
	private String name;
	@Column(length = 64)
	private String pwd;
	@Column(length = 20)
	private String phone;
	@Column(length = 100)
	@Email(message = "邮箱地址格式错误！")
	private String email;
	@Column(length = 20)
	@NotEmpty(message = "班级不能为空！")
	private String clsSn;
	@Column(columnDefinition = "tinyint default 1")
	private Byte role;
	@Column(length = 100)
	private String head;

}
